package com.wf.day_0608.test4;

import java.util.ArrayList;
import java.util.Collections;

/**
 * @author mpk
 * @since 2024/6/9 10:10:01
 */
public class MyThread extends  Thread{

     ArrayList<Integer>  list;


    public MyThread(String name, ArrayList<Integer> list) {
        super(name);
        this.list = list;
    }


    @Override
    public void run() {

        while (true)
            synchronized (MyThread.class)

            {
                if(list.isEmpty())
                {

                    break;
                }
                else
                {

                    Collections.shuffle(list);
                    Integer i = list.remove(0);

                    System.out.println(Thread.currentThread().getName() + "又产生了一个" +i + "元大奖");

                }


            }

    }
}
